#include <iostream>
#include <vector>
using namespace std;

int n, m;
int maxscore = 0;

int dx[4] = { 0, 0, 1, -1 };
int dy[4] = { 1, -1, 0, 0 };

int dfs(vector<vector<char>>& word, int i, int j)
{

    for (int k = 0; k < 4; k++)
    {
        int x = i + dx[k], y = j + dy[k];
        if (x >= 0 && x < n && y >= 0 && y < m && (word[x][y] == 'l' || word[x][y] == 'o' || word[x][y] == 'v' || word[x][y] == 'e'))
        {
            int ret = 0;
            if (word[x][y] == 'l') ret = 4;
            else if (word[x][y] == 'o') ret = 3;
            else if (word[x][y] == 'v') ret = 2;
            else if (word[x][y] == 'e') ret = 1;
            return ret + dfs(word, x, y);
        }
    }
    return 0;
}


int main()
{
    cin >> n >> m;

    vector<vector<char>> word(n, vector<char>(m));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            char x;
            cin >> x;
            word[i][j] = x;
        }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            maxscore = max(maxscore, dfs(word, i, j));

    cout <<  maxscore;

    return  0;
}
